<template>
  <div class="">
    <!-- 
      https://www.vuemastery.com/blog/nuxt-3-state-mangement-pinia-vs-usestate/
      这篇文章很好的解释了应该选择使用 useState 还是 Pinia
      简单的来说
        复杂的使用 Pinia
        简单小型的使用 useState
     -->
    <h3 class="mb-10">useState 结合 composables 做状态管理 与 pinia 做状态管理</h3>
    Counter: {{ counter }}
    <el-button @click="counter++">+</el-button>
    <el-button @click="counter--">-</el-button>
    Count: {{ store.count }}
    <el-button @click="store.increment">+</el-button>
    <g-state></g-state>
  </div>
</template>

<script setup>
import { useCounterStore } from '~/stores/myStore.js'
const store = useCounterStore()
const counter = useState('counter', () => Math.round(Math.random() * 1000))
</script>

<style lang="scss" scoped></style>